package com.zhongya.example.fragment.myview

import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.zhongya.example.R
import com.zhongya.example.adapter.ExampleAdapter
import com.zhongya.example.bean.ExampleBean
import com.zhongya.example.databinding.ExampleFragmentMyViewBinding
import com.zhongya666.library.base.fragment.BaseDbFragment
import com.zhongya666.library.ext.initClose
import com.zhongya666.library.view.nav
import com.zhongya666.library.view.navigateAction

/**
 * GitHub/Gitee：zhongya666 2021/7/27 10:59
 *
 */
class MyViewFragment :
    BaseDbFragment<ExampleFragmentMyViewBinding>(R.layout.example_fragment_my_view) {

    override fun initView() {

        mDatabind.include.toolbar.initClose("自定义控件") {
            nav().popBackStack()
        }

        mDatabind.includeRv.refreshLayout.setEnableRefresh(false)
        mDatabind.includeRv.refreshLayout.setEnableLoadMore(false)

        var adapter = ExampleAdapter(
            arrayListOf(
                ExampleBean("view的学习和视图动画", "日常学习记录"),
                ExampleBean("初级--属性动画", "日常学习记录"),
                ExampleBean("初级--动画进价", "pathmeasure和svg"),
                ExampleBean("初级--绘图进阶", "内赛尔曲线"),
                ExampleBean("初级--Canvas与图层", "Canvas与图层"),
                ExampleBean("初级--Android画布", "Android画布"),
                ExampleBean("高级--第三章", "派生类的选择与实例"),
                ExampleBean("高级--第六章", "工具类"),
                ExampleBean("高级--第七章", "itemTouchHelper"),
            )
        )

        mDatabind.includeRv.recyclerView.layoutManager =
            StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
        mDatabind.includeRv.recyclerView.adapter = adapter

        adapter.setOnItemClickListener { _, _, position ->
            when (position) {
                0 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_viewStudyFragment)
                }
                1 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_propertyAnimationFragment)
                }
                2 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_pathMeasureFragment)
                }
                3 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_paintFragment)
                }
                4 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_canvasAndLayerFragment)
                }
                5 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_bitmapFragment)
                }
                6 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_part3Fragment)
                }
                7 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_part6Fragment)
                }
                8 -> {
                    nav().navigateAction(R.id.action_myViewFragment_to_part7Fragment)
                }
            }
        }

    }

    override fun createObserver() {

    }

    override fun lazyLoadData() {

    }
}